<template>
	<view class="wrap">
		<view class="title">
			{{info.title||''}}
		</view>
		<view class="headline">
			 {{info.updateTime||''}}
		</view>
		<view class="main">
			<u-parse :html="info.contentHtml"></u-parse>
			<!-- <img src="../static/image/008.png" alt="">
			<view class="info">
				28年红旗不倒，2次革命武装起义，12支红军队伍，10万英雄儿女，59位开国将军……这些数字背后是一个光荣的名字——安徽省六安市金寨县。

				这里是革命老区，也曾是全国贫困程度最深的地区之一。新中国成立后，为根治淮河水患修建水库，金寨10多万群众搬离家园、移居深山。2011年，金寨列入大别山集中连片特困地区县，全县210个山区村中有71个是贫困村，花石乡大湾村是其中最贫困的山村之一。

				“大湾好风景，出门就是岭，不是石头绊了脚，就是茅草割了颈。”这曾是大湾村的真实写照。村里的干部群众为了摆脱贫困奋斗了几十年，但直到2014年底，全村37个村民组928户3348人中仍有554人未脱贫，贫困发生率近17%。

			</view> -->
			<view class="zan-collect flex flex-between" v-if="type!=1">
				<view class="zans flex flex-v-center flex-h-center" v-if="info.zaned==1">
					<image src="../static/image/012.png" mode=""></image>
					<text class="zaned" @click="doen(0,info.id)">已点赞{{info.zanNum||0}}</text>
				</view>
				<view class="zans flex flex-v-center flex-h-center" v-else>
					<image src="../static/image/011.png" mode=""></image>
					<text class="zan" @click="doen(0,info.id)">点赞{{info.zanNum||0}}</text>
				</view>

				<view class="collects flex flex-v-center flex-h-center" v-if="info.collected==1">
					<image src="../static/image/010.png" mode=""></image>
					<text class="collected" @click="doen(1,info.id)">已收藏{{info.collectNum||0}}</text>
				</view>
				<view class="collects flex flex-v-center flex-h-center" v-else>
					<image src="../static/image/009.png" mode=""></image>
					<text class="collect" @click="doen(1,info.id)">收藏{{info.collectNum||0}}</text>
				</view>

			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				zan: 1,
				collect: 1,
				id: '',
				info: {},
				type: '',

			}
		},
		onLoad(options) {
			
			if (options.item&&!options.id) {
				this.info = JSON.parse(options.item)
				console.log(this.info)

			}
			 
			 if (options.id) {
				this.id = options.id;
				this.getDetail();
			}
		},
		methods: {
			getDetail() {
				this.$https.request('/cli/news/getInfo', true, {
					id: this.id
				}).then((res) => {
					if (res.code == 0) {
						this.info = res.data;

					}else if (res.code == 201) {
						uni.navigateTo({
							url:'../login/login'
						})

					} else {
						this.LoadingMsg(res.msg);
						setTimeout(function() {
							uni.hideLoading();
						}, 1000)
					}

				})
			},
			doen(type,id){
				if (type == 0) {
					this.$https.request('/cli/collectzan/operation', true, {
						dataType: 2,
						dataId: id
					}).then((res) => {
						if (res.code == 0) {
							this.getDetail();
						}else if (res.code == 201) {
						uni.navigateTo({
							url:'../login/login'
						})

					} else {
							this.LoadingMsg(res.msg);
							setTimeout(function() {
								uni.hideLoading();
							}, 1000)
						}
								
					})
				}
				if (type == 1) {
						this.$https.request('/cli/collectzan/operation', true, {
							dataType: 1,
							dataId: id
						}).then((res) => {
							if (res.code == 0) {
								this.getDetail();
							} else if (res.code == 201) {
									uni.navigateTo({
										url:'../login/login'
									})

								}else {
								this.LoadingMsg(res.msg);
								setTimeout(function() {
									uni.hideLoading();
								}, 1000)
							}
				
						})
					}
				}
		}
	}
</script>

<style scoped lang="scss">
	.wrap {
		padding: 30rpx;

		.title {
			font-family: HiraginoSansGB-W6;
			font-size: 36rpx;
			color: #333;
			padding: 35rpx 0;
		}

		.headline {
			font-family: HiraginoSansGB-W6;
			font-size: 24rpx;
			color: #666;
		}

		.main {
			padding-top: 30rpx;
			image {
				width: 100%;
				margin: 35rpx 0;
			}

			.info {
				font-family: HiraginoSansGB-W3;
				font-size: 30rpx;
				color: #000;
				line-height: 60rpx;
			}

			.zan-collect {
				.zans {
					width: 50%;

					image {
						width: 40rpx;
						height: 40rpx;
					}

					.zan {
						font-family: HiraginoSansGB-W3;
						font-size: 30rpx;
						color: #333;
					}

					.zaned {
						font-family: HiraginoSansGB-W3;
						font-size: 30rpx;
						color: #2A90FF;
					}

				}

				.collects {
					width: 50%;

					image {
						width: 40rpx;
						height: 40rpx;
					}

					.collect {
						font-family: HiraginoSansGB-W3;
						font-size: 30rpx;
						color: #333;
					}

					.collected {
						font-family: HiraginoSansGB-W3;
						font-size: 30rpx;
						color: #2A90FF;
					}

				}
			}
		}
	}
</style>
